import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/models/user/xindong_intimate_user.dart';
import 'package:xindong/utils/xindong_text_util.dart';
import 'package:xindong/widgets/common/xindong_common_dot.dart';
import 'package:xindong/widgets/xindong_avatar.dart';

class XinDongChatIntimateCell extends StatelessWidget {
  final XinDongIntimateUser model;

  const XinDongChatIntimateCell({Key? key, required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => XinDongPageSingleton.instance.jumpToChatYeMian(userClass: model),
      behavior: HitTestBehavior.opaque,
      child: Container(
        height: 70.0,
        color: DZColors.cellColor,
        padding: const EdgeInsets.only(left: kPaddingValue, right: kPaddingValue),
        child: Stack(
          alignment: Alignment.center,
          children: [
            Row(
              children: [
                Stack(
                  fit: StackFit.loose,
                  clipBehavior: Clip.none,
                  children: [
                    XinDongAvatar(url: model.user_head, size: 50),
                    if (model.is_online == 1)
                      Positioned(
                        top: -3,
                        right: -3,
                        child: XinDongCommonDot(color: DZColors.statusCorrectColor, size: 10),
                      ),
                  ],
                ),
                const SizedBox(width: 10),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SizedBox(
                        height: 22,
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Flexible(
                              child: Text(
                                model.user_name ?? "",
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                                style: TextStyle(
                                  color: model.isHuiYuan ? Colors.red : DZColors.titleColor,
                                  fontSize: 15,
                                  fontWeight: FontWeight.w600,
                                  height: 1.2,
                                ),
                              ),
                            ),
                            const SizedBox(width: 8),
                          ],
                        ),
                      ),
                      const SizedBox(height: 4),
                      Flexible(
                        child: Text(
                          "${model.user_age}岁${TextUtil.isEmpty(model.statureText) ? "" : " | ${model.statureText}"}${TextUtil.isEmpty(model.occupation) ? "" : ""
                              " | ${model.occupation}"}",
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: const TextStyle(fontSize: 14, color: DZColors.contentColor),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            Positioned(
              right: 0,
              child: Text(
                "亲密度${model.intimate}°C",
                style: TextStyle(color: DZColors.hexStringColor("#F23D9F"), fontSize: 12),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
